<template>
    <div>
        <wd-header  title="用户反馈">
            <span class="iconfont" @click="goback" slot="left">&#xe697;</span>
        </wd-header>
        <div class="container">
            <textarea placeholder="如果您对记忆大师有什么意见或建议，请在这里告诉我们" v-model="content" />
        </div>
        <div class="footer" @click="submit">
        	<button>提交</button>
        </div>
    </div>
</template>
<script>
export default {
    name: 'recommend',
    data() {
        return {
            content: null,
            auth: JSON.parse(localStorage.user),
            submiturl:'http://www.jydsapp.com/jydsApi/api/h5/system/fedBack'
        }
    },
    methods: {
        goback() {
            this.$router.go(-1)
        },
        submit(){
        	let str = `{"userPhone":"${this.auth.user.phoneNum}","token":"${this.auth.token}","content":"${this.content}"}`
        	if(!this.content){
        		this.$Toast({
        		    content: '请填写信息'
        		})
        	}else if(this.content.length<10){
        		this.$Toast({
        		    content: '不能少于10字'
        		})
        	}else{
        		this.fetch({
        		    method: 'post',
        		    url: this.submiturl,
        		    params: {
        		        "paramStr": str
        		    }
        		}).then((response) => {
        			let res = response.data
        			if(res.code == 200){
        				this.$Toast({
        				    content: '提交成功'
        				})
        				this.content = ''
        			}else if (res.code == 103) {  //五天内未登录 token失效跳转到登陆页面
                        localStorage.removeItem('user')
                        this.$Toast({
                            content: '请重新登录'
                        })
                        this.$router.replace('/login')
                    }else{
                        this.$Toast({
                            content: res.message
                        })
                    }
        		}).catch((error) => {
        		    this.$Toast({
        		        content: error.data.message
        		    })
        		})
        	}
        }
    }
}
</script>
<style lang="scss" scoped>

.container {
    width: 100%;

    textarea {
        width: 100%;
        padding: 0.740741rem;
        display: inline-block;
        box-sizing: border-box;
        outline: 0;
        border: 0;
        resize:none;
    }
}

.footer {
    padding: 0 0.740741rem;
    margin-top: 0.462963rem;
    display: flex;
    margin-top: 5%;
    button {
        color: #aaa;
        flex: 1;
        padding: 0.185185rem 0;
        background: none;
        border: 1px solid #aaa;
    }
}

</style>
